from UserDict import DictMixin

def indexof(array, value):
	for i, a in enumerate(array):
		if a == value:
			return i
	return -1

def arg(args, key, default=None):
	i = indexof(args, key)
	#found it... take it out and return
	if i!=-1:
		args.pop(i)
		return args.pop(i)
	return default

class odict(DictMixin):    
    def __init__(self):
        self._keys = []
        self._data = {}
        
    def __setitem__(self, key, value):
        if key not in self._data:
            self._keys.append(key)
        self._data[key] = value
        
    def __getitem__(self, key):
        return self._data[key]
    
    def __delitem__(self, key):
        del self._data[key]
        self._keys.remove(key)
        
    def keys(self):
        return list(self._keys)
		
	def values(self):
		ks = self.keys()
		vs = []
		for k in ks:
			vs.append(self._data[k])
		return vs